<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <title>评论管理页面</title>
    <th:block th:replace="~{/backstage/common_resources::common_css}"/>
    <th:block th:replace="~{/backstage/common_resources::common_js}"/>
</head>

<!-- 第二个设置颜色-->
<body class="hold-transition skin-black-light sidebar-mini">
<!--    头部-->
    <header th:replace="~{/backstage/common_header::header}"></header>
<!--边栏-->
    <aside th:replace="~{/backstage/common_aside::aside}"></aside>

<!-- 内容区域 -->
<!-- @@master = admin-layout.html-->
<!-- @@block = content -->

<div class="content-wrapper">

    <!-- 内容头部 -->
    <section class="content-header">
        <h1>
            评论管理
            <small>评论列表</small>
        </h1>
        <ol class="breadcrumb">
            <li><a th:href="@{/backstage/index}"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a th:href="@{/backstage/comment/all}">评论管理</a></li>
            <li class="active">评论列表</li>
        </ol>
    </section>
    <!-- 内容头部 /-->

    <!-- 正文区域 -->
    <section class="content">

        <!-- .box-body -->
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">评论列表</h3>
            </div>

            <div class="box-body">



                <!-- 数据表格 -->
                <div class="table-box">



                    <!--工具栏-->
                    <div class="box-tools pull-right">
                        <div  class="form-group form-inline">
                            <div class="has-feedback">
                                <input id="titleAuthor" onkeydown="entersearch()" type="text" class="form-control input-sm" placeholder="帖子名,评论作者">
                                <span  class="glyphicon glyphicon-search form-control-feedback"></span>
                            </div>
                        </div>

                    </div>
                    <!--工具栏/-->
                    <!--数据列表-->
                    <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                          <thead>
                        <tr>
                            <th class="" style="padding-right:0px;">
                                <input id="selall" type="checkbox" class="icheckbox_square-blue">
                            </th>
                            <th>评论的帖子</th>
                            <th>评论作者</th>
                            <th>评论发表时间</th>
                            <th>评论状态</th>

                            <th class="text-center">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!--adminPage.records返回当前页数据返回值是list-->
                        <tr th:each="comment:${commentPage.records}">
                            <td><input name="ids" type="checkbox"></td>
                            <td th:text="${comment.post.postTitle}"></td>
                            <td th:text="${comment.member.username}"></td>
                            <td th:text="${comment.time}"></td>
                            <td class="text-aqua" th:text="${comment.status}"></td>

                            <td class="text-center">
                                <a class="btn bg-blue btn-xs" th:href="@{/backstage/comment/desc(coid=${comment.coid})}">评论详情</a>
                                <a th:onclick="|javascirpt:updateStatus(${comment.coid})|" class="btn bg-gray btn-xs">开启/禁用</a>

                            </td>
                        </tr>

                        </tr>

                        </tbody>

                    </table>
                    <!--数据列表/-->


                </div>
                <!-- 数据表格 /-->


            </div>
            <!-- /.box-body -->

            <!-- .box-footer-->
            <div class="box-footer">
                <div class="pull-left">
                    <div class="form-group form-inline">
                        总共<span th:text="${commentPage.pages}"></span> 页，
                        共<span th:text="${commentPage.total}"></span> 条数据。
                    </div>
                </div>

                <div class="box-tools pull-right">
                    <ul class="pagination">

                    </ul>
                </div>

            </div>
            <!-- /.box-footer-->



        </div>

    </section>
    <!-- 正文区域 /-->

</div>
<!-- @@close -->
<!-- 内容区域 /-->


<!--底部-->
<footer th:replace="~{/backstage/common_footer::footer}"></footer>

<script th:inline="javascript">


    //弹出是否禁用的操作
    function updateStatus(pid){
        if (confirm("确定要禁用/开启吗")){
            //跳转到此路径
            location.href="/backstage/post/updateStatus?pid="+pid;
        }
    }

    //根据用户名称搜索用户
    function entersearch(){
        var event = window.event || arguments.callee.caller.arguments[0];
        if (event.keyCode === 13)
        {
            var titleAuthor=document.getElementById("titleAuthor").value;
            //跳转到此路径
            location.href="/backstage/comment/search?titleAuthor="+titleAuthor;
        }
    }

    //分页
    var currentPage =[[${commentPage.current}]]
    var pages =[[${commentPage.pages}]]
    var context =[[${#servletContext.contextPath}]]//获取项目路径
    // 分页插件
    $('.pagination').bootstrapPaginator({
        bootstrapMajorVersion: 3, // bootstrap版本
        currentPage: currentPage, // 当前页
        totalPages: pages, // 总页数
        numberOfPages: 5, // 最多显示多少页
        itemTexts: function (type, page, current) {
            switch (type) {
                case "first":
                    return "首页";
                case "prev":
                    return "上一页";
                case "next":
                    return "下一页";
                case "last":
                    return "末页";
                case "page":
                    return page;
            }
        },
        onPageClicked: function (event, originalEvent, type, page) { // 点击页码执行的方法

            location.href = context+"/backstage/comment/all?page=" + page;
        }

    })
</script>

</body>

</html>